<template>
  <div>
    <v-top></v-top>
    <div class="xiangqing">
      <div class="top">
        <p>{{obj.goodsname}}</p>
        <ul>
          <li>
            商品
            <span></span>
          </li>
          <li>
            评价
            <span></span>
          </li>
          <li>
            详情
            <span></span>
          </li>
          <li>
            推荐
            <span></span>
          </li>
        </ul>
      </div>
      <img :src="'http://localhost:3000'+obj.img" alt class="datu" />
      <div v-html="obj.description"></div>
      <div class="num clearfix">
        <span>￥</span>
        <span>{{obj.market_price}}</span>
        <del>{{"￥"+obj.price}}</del>
        <div class="shoucang">
          <img src="../../assets/img/页面-4-商品详情_05.gif" alt />
          <p>收藏</p>
        </div>
      </div>
      <div class="wenzi clearfix">
        <p class="p1">{{obj.goodsname}}</p>
        <p class="p2">{{obj.detail}}</p>
        <br />
        <div>规格：{{obj.specsname}}</div>
        <button v-for="item in obj.specsattr" :key="item">{{item}}</button>
        <!-- <span class="span1">11.11限时299元起</span> -->
        <br />
        <br />
        <p class="p3 clearfix">
          此商品于2020年11月11日0点结束闪购特卖，品牌美妆闪购专场
          <a href="#">查看 ></a>
        </p>
      </div>
      <div class="box clearfix">
        <p class="p4">领券</p>
        <div class="box1 clearfix">
          <img src="../../assets/img/页面-4-商品详情_09.gif" alt />
          <img src="../../assets/img/页面-4-商品详情_11.gif" alt />
          <img src="../../assets/img/页面-4-商品详情_13.gif" alt />
        </div>
        <p class="p4 clearfix">分期</p>
        <span class="p4 p5">可选3/6/12期</span>
      </div>
    </div>
    <br />
    <br />
    <div class="bottom clearfix">
      <div>
        <img src="../../assets/img/页面-4-商品详情_19.gif" alt />
        <p>客服</p>
      </div>
      <div>
        <img src="../../assets/img/页面-4-商品详情_22.gif" alt />
        <p>店铺</p>
      </div>
      <div>
        <img src="../../assets/img/页面-4-商品详情_25.gif" alt />
        <p>购物车</p>
      </div>
      <input type="button" value="加入购物车" @click="add" />
      <input type="submit" value="立即购买" />
    </div>
  </div>
</template>

<script>
import {Toast} from "vant"
import {reqDetail} from "../../http/api"
import {reqAdd} from "../../http/api"
export default {
  data() {
    return {
      obj: {},
    };
  },
  mounted() {
    // console.log(this.$route);
    reqDetail({ id:this.$route.params.id}).then(res=>{
      // console.log(res);
      if(res.data.code===200){
        this.obj=res.data.list[0]?res.data.list[0]:{}
        this.obj.specsattr=this.obj.specsattr.split(",")
      }
    })
  },
  methods:{
    add(){
      reqAdd({
        uid:JSON.parse(localStorage.getItem("user")).uid,
        goodsid:this.obj.id,
        num:1
      }).then(res=>{
        if(res.data.code==200){
          Toast(res.data.msg)
          this.$router.push("/index/shop")
        }
      })
    }
  }
};
</script>

<style scoped>
.xiangqing {
  margin: 0 auto;
}
.top {
  background: linear-gradient(to bottom, #ff6040, #ff887c);
}
.top p {
  line-height: 0.8rem;
  text-align: center;
  font-size: 0.3rem;
  color: white;
}
.top ul {
  height: 0.55rem;
  font-size: 0.28rem;
  color: white;
  display: flex;
  justify-content: space-around;
}
.top ul li {
  line-height: 0.5rem;
  text-align: center;
}
.top ul li span {
  width: 0.4rem;
  height: 2px;
  background-color: white;
  display: block;
  display: none;
}
.top ul li:hover span {
  display: block;
}
.top ul li:hover {
  font-size: 0.3rem;
  font-weight: bold;
}
.datu {
  display: block;
  margin: 0 0.1rem;
  width: 7rem;
  height: 7.5rem;
}
.num {
  margin: 0.1rem;
}
.num span:nth-child(1) {
  color: orangered;
}
.num span:nth-child(2) {
  color: orangered;
  font-size: 0.45rem;
}
.num del:nth-child(3) {
  color: #9e9e9e;
  font-size: 0.16rem;
}
.shoucang {
  float: right;
  right: 0.1rem;
}
.clearfix {
  *zoom: 1;
}
.clearfix::after {
  contain: "";
  display: block;
  clear: both;
}
.shoucang {
  text-align: center;
}
.shoucang img {
  width: 0.21rem;
  height: 0.21rem;
  margin-left: 0.05rem;
}
.shoucang p {
  color: orangered;
  font-size: 0.16rem;
}
.wenzi .p1 {
  font-size: 0.3rem;
}
.wenzi .p2 {
  font-size: 0.28rem;
  color: #9e9e9e;
}
.wenzi .span1 {
  background-color: #ff6040;
  font-size: 0.18rem;
  color: white;
  line-height: 0.3rem;
  letter-spacing: 1px;
}
.wenzi .p3 {
  background-color: #f2f2f2;
  color: #9e9e9e;
  font-size: 0.2rem;
}
.p3 a {
  float: right;
}
.wenzi {
  margin: 0.1rem;
}
.box {
  height: 0.5rem;
}
.p4 {
  float: left;
  line-height: 0.4rem;
  height: 0.4rem;
  margin: 0 0.2rem;
  font-size: 0.32rem;
}
.box1 img {
  float: left;
  height: 0.32rem;
  margin: 0.05rem 0.2rem 0.05rem 0;
}
.box1 img:nth-child(1) {
  width: 0.78rem;
}
.box1 img:nth-child(2) {
  width: 0.66rem;
}
.box1 img:nth-child(3) {
  width: 0.64rem;
}
.p5 {
  margin-left: 0rem;
  color: #9e9e9e;
}
.bottom {
  height: 1.67rem;
}
.bottom div {
  float: left;
  margin: 0.16rem 0.25rem;
}
.bottom img {
  width: 0.4rem;
  height: 0.4rem;
}
.bottom input {
  width: 1.8rem;
  height: 1rem;
  font-size: 0.33rem;
  font-weight: bold;
  line-height: 1rem;
  float: right;
}
.bottom input:nth-child(4) {
  background-color: #ffcc66;
  color: #663014;
}
.bottom input:nth-child(5) {
  background-color: orangered;
  color: white;
}
.bottom .p10 {
  width: 1.8rem;
  height: 0.1rem;
  background-color: black;
  border-radius: 5px;
  position: absolute;
  top: 13.5rem;
  left: 3rem;
}
</style>